import { AxiosBase, statusCodeProcessingCore } from '@zealforchange/axiospackage'
const errorStatusCodeHandler: statusCodeProcessingCore = new Map().set(404, {
  fn() {},
})
export const BASE_AJAX_URL = '/api'
const AXIOS_DEFAULT_CONFIG = {
  baseURL: BASE_AJAX_URL,
  timeout: 20000,
  maxContentLength: 2000,
  headers: {},
}
const httpConfig = new AxiosBase({
  ...AXIOS_DEFAULT_CONFIG,
  errorStatusCodeProcessing: errorStatusCodeHandler,
  tranform: {
    // 请求前前拦截器
    requestInterceptors(config) {
      return config
    },
    // 响应成功成功拦截器
    responseInterceptors(res) {
      return Promise.resolve(res.data)
    },
    // 请求前拦截器错误处理
    requestInterceptorsCatch() {},
    // 响应后错误拦截
    responseInterceptorsCatch() {},
  },
})
export { httpConfig }
